<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/js/jquey.3.31.js"></script>
<script type="text/javascript" src="/js/vue.js"></script>
</head>
<body>

	<select id="depart">
		
	</select>
	<input id="msg">
	<input type="button" id="send" value="发送">
	<div id="msgdiv"></div>

	<script type="text/javascript">
		$(function() {
			var ws = null;
			$.ajax({
				url : "http://localhost:80/login/4",
				success : function(result) {
					console.log(result);
					ws = new WebSocket("ws://localhost:80/myHandler")

					ws.onopen = function() {
						console.log("onpen");
						ws.send("{}");
					}

					ws.onclose = function() {
						console.log("onclose");
					}

					ws.onmessage = function(msg) {
						$("#msgdiv").append(msg.data + "<hr>");
						console.log("msgdata:" + msg.data);
					}
				}
			});
			
			$("#send").click(function(){
				ws.send($("#msg").val());
			});
		})
	</script>
</body>
</html>